<template>
  <div class="container">
    首页
    <button v-permission="['admin']" @click="toPower">权限</button>
    <button @click="toLogOut">登出</button>
  </div>
</template>

<script>
import permission from '@/directive/permission/index.js'
import { removeToken } from '@/utils/auth'
export default {
  name: '',
  components: {},
  props: {},
  data () {
    return {

    }
  },
  computed: {},
  directives: { permission },
  watch: {},
  created () {},
  mounted () {},
  methods: {
    toPower () {
      this.$router.push({
        path: '/power'
      })
    },
    toLogOut () {
      // 清除vuex中的 token roles
      this.$store.commit('SET_TOKEN', '')
      this.$store.commit('SET_ROLES', [])
      // 清除缓存中的 token
      removeToken()
      // 刷新页面 由于没有token所以跳转到登录页面
      location.reload()
    }
  }
}
</script>

<style scoped lang="">

</style>
